/*
 * Class Liver.java
 * 9.06.2012
 * 
 * Class represents liver organ.
 */

package human;

/**
 * Class implements a model of human liver.
 * It has a number of characteristics (such as glucose and cholesterol level)
 * which changes according human activities.
 * Liver could be cause of death because it's vital organ.
 * 
 * @author Vasyl Khyzhniak
 * @version 1.0
 */
public class Liver extends Organ {
	private int detoxification;		//opportunity to neutralize toxic elements
	private int cholesterol;			//level of cholesterol
	private int glucose;				//level of glucose
	
	/**
	 * Liver Class Constructor
	 * Sets all live characteristics to newborn level which
	 * is equal to zero.
	 * Also defines liver as necessary for life organ 
	 * (isNecessaryForLife = true)
	 * @author Vasyl Khyzhniak
	 */
	public Liver() {
		this.health = 0;
		this.cholesterol = 0;
		this.detoxification = 0;
		this.glucose = 0;
		this.isNecessaryForLife = true;
		this.upperLimit = 100;
		this.lowerLimit = -100;
	}
	
	/**
	 * Changes cholesterol level on value
	 * @param value Defines the change of cholesterol level
	 * @author Vasyl Khyzhniak
	 */
	public void changeCholesterol(int value) {
		if (this.cholesterol + value > this.upperLimit){				//keeps value in limit [-100,100]
			this.cholesterol = this.upperLimit;
		} else if (this.cholesterol + value < this.lowerLimit) {
			this.cholesterol = this.lowerLimit;
		} else {
			this.cholesterol += value;
		}
	}
	
	/**
	 * Changes detoxifacation level on value
	 * @param value Defines the change of detoxification level
	 * @author Vasyl Khyzhniak
	 */
	public void changeDetoxification(int value) {
		if (this.detoxification + value > this.upperLimit){				//keeps value in limit [-100,100]
			this.detoxification = this.upperLimit;
		} else if (this.detoxification + value < this.lowerLimit) {
			this.detoxification = this.lowerLimit;
		} else {
			this.detoxification += value;
		}
	}
	
	/**
	 * Changes glucose level on value
	 * @param value Defines the change of glucose level
	 * @author Vasyl Khyzhniak
	 */
	public void changeGlucose(int value) {
		if (this.glucose + value > this.upperLimit){				//keeps value in limit [-100,100]
			this.glucose = this.upperLimit;
		} else if (this.glucose + value < this.lowerLimit) {
			this.glucose = this.lowerLimit;
		} else {
			this.glucose += value;
		}		
	}
		
	/**
	 * @return value of cholesterol level
	 * @author Vasyl Khyzhniak
	 */
	public int getCholesterol() {
		return this.cholesterol;
	}

	/**
	 * @return value of detoxification
	 * @author Vasyl Khyzhniak
	 */
	public int getDetoxification() {
		return this.detoxification;
	}

	/**
	 * @return value of glucose
	 * @author Vasyl Khyzhniak
	 */
	public int getGlucose() {
		return this.glucose;
	}
}
